""""
简易购物系统
"""
Merchandise = [("牛奶",5),("西瓜",75),("鸡蛋",1),("香蕉",55)]
shop_list = []
money = float(input("请输入购物资金: "))
while True :
    print("*"*30)
    print("商品列表如下：")
    for i , Merchandises in enumerate(Merchandise) :
        print(f"{i+1}.商品：{Merchandise[0]},价格：{Merchandise[1]}")
    print("*"*30)
    option = input ("输入购买物品序号（返回请按Q）：")
    if option.isdigit():
        option = int(option)
        if 0 <= option-1 < len(Merchandise) :
            option_Merchandise = Merchandise[option - 1]
            if option_Merchandise[1] <= money :
                shop_list.append(option_Merchandise)
                money -= option_Merchandise[1]
                print("购买成功")
            else: 
                print(f"购买失败，余额为{money}")    
        else:
            print("商品不存在")
    elif option == "q":
        print("-" * 10 ,"购物清单","-" * 10 )
        for i in shop_list :
            print(f"{i[0]},{i[1]}")
            
        break
    else :
        print("输入不合法")
